const state = {
  /**
   * 用户信息
   */
  profile: {
    id: null,
    student: [],
    type:'',
  },
  permissions: {}
}

const getters = {}

const actions = {
  fetchUser ({commit}) {
    return new Promise((resolve, reject) => {
      axios.get('/api/user/profile').then((response) => {
        commit('setUserProfile', response.data.data)
        resolve()
      }).catch((error) => {
        reject(error)
      })
    })
  }
}

const mutations = {
  setUserProfile (state, user) {
    state.profile = user
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
